<template>
  <div>
    <el-card shadow="never">
      <el-button class="mb20" @click="handleBack">返回</el-button>
      <el-tabs class="classify-tabs" :tab-position="tabPosition" type="border-card">
        <el-tab-pane v-for="(item,index) in listData" :key="index" :label="item.name ">
          <eval-table :list="item" ref="evalTable" />
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import EvalTable from './Table'
import { removeSession, setSession, getSession } from '@/utils/util'
import { taskListGet } from '@/api/satisfaction'

export default {
  components: {
    EvalTable
  },
  data() {
    return {
      tabPosition: 'left',
      row: this.$route.params.row || getSession('satisListRow'),
      listData: [],
      tableArr: []
    }
  },
  async created() {
    if (this.row) {
      setSession('satisListRow', this.row)
      const res = await taskListGet({ internalTaskId: this.row.internalTaskId })
      console.log('res', res)
      if (res && res.data.length > 0) {
        let arr = []
        let all = []
        res.data.map(v => {
          if (v.internalNoteVOList) {
            all = [...all, ...v.internalNoteVOList]
          } else {
            all = [...all]
          }
        })
        console.log('all', all)
        this.tableArr = [...arr]
        res.data.unshift({
          name: '被考评对象',
          internalNoteVOList: all,
          size: null
        })
        this.listData = res.data
        console.log('listData', this.listData)
      }
    } else {
      this.$message.error('页面发生错误，即将跳转回列表页')
      // setTimeout(() => {
      //   this.$router.push({
      //     name: 'satisfactionTask'
      //   })
      // }, 1000)
    }
  },
  methods: {
    handleBack() {
      this.$router.push({ name: 'satisfactionTask' })
      removeSession('satisListRow')
    }
  }
}
</script>

<style scoped>
.classify-tabs >>> .el-tabs__item {
  text-align: center;
}
</style>
